package day07;

import jdk.internal.org.objectweb.asm.TypeReference;

import java.beans.beancontext.BeanContext;
import java.lang.ref.SoftReference;
import java.lang.reflect.GenericArrayType;
import java.util.Random;
import java.util.Scanner;
import java.util.zip.DeflaterOutputStream;

public class HomeWord2 {
    public static void main(String[] args) {
        /*
        Scanner scan=new Scanner(System.in);
        int num=(int) (Math.random()*1000+1);
        System.out.println(num);
        while (true){
            System.out.println("猜吧！");
            int gu= scan.nextInt();
            if (gu>num){
                System.out.println("猜大了");
            }else if (gu<num){
                System.out.println("猜小了");
            }else{
                System.out.println("恭喜你猜对了");
                break;
            }
        }*/
        /*
        String code = ge(6);
        System.out.println("验证码："+code);*/
        /*
        for (int i=2;i<=100;i++){
            boolean flag=true;
            for (int num=2;num<=i/2;num++){
                if (i%num==0){
                    flag=false;
                    break;
                }
            }
            if (flag){
                System.out.print(i+"/t");
            }
        }*//*
        int num=12;
        boolean flag= true;
        for (int i=2;i<num;i++){
            if (num%i==0){
                flag=false;
                break;
            }
        }
        if (flag){
            System.out.println(num+"是素数");
        }else{
            System.out.println(num+"不是素数");
        }*/
        /*
        Scanner scan =new Scanner(System.in);
        System.out.println("请输入机票原价");
        double price=scan.nextDouble();
        System.out.println("请输入月份");
        int month=scan.nextInt();
        System.out.println("请选择舱位：1.头等舱 2.商务舱 3.经济舱");
        int type=scan.nextInt();
        double fin=cal(price,month,type);
        if (fin!=1){
            System.out.println("机票的最终价格为："+fin);
        }*/
        double[] sc=ent();
        double avg=cal(sc);
        System.out.println("平均分为："+avg);





    }
    public static double[] ent(){
        Scanner scan=new Scanner(System.in);
        double[] sc=new double[6];
        for (int i=0;i<sc.length;i++){
            System.out.println("请录入第"+(i+1)+"个评委的分数");
            sc[i]=scan.nextDouble();
        }
        return sc;
    }
    public static double ca(double[] sc){
        double to=cal(sc);
        double avg=to/(sc.length-2);
        return avg;
    }
    public static double cal(double[]sc){
        double to=0.0;
        double max=sc[0];
        double min=sc[0];
        for (int i=0;i<sc.length;i++){
            if (sc[i]>max){
                max=sc[i];
            }
            if (sc[i]<min){
                min=sc[i];
            }
            to+=sc[i];
        }
        return to-max-min;
    }



    /*
    public static double cal(double price,int month,int type){
        double fin = 0.0;
        if (month<1||month>12){
            System.out.println("月份输入错误");
            return -1;
        }
        if (type<1||type>3){
            System.out.println("舱位输入错误");
            return -1;
        }
        if (month>=5&&month<=10){
            switch (type){
                case 1:
                    fin=price*0.9;
                    break;
                case 2:
                    fin=price*0.85;
                    break;
                case 3:
                    fin=price*0.8;
                    break;
            }
        }else{
            switch (type){
                case 1:
                    fin=price*0.7;
                    break;
                case 2:
                    fin=price*0.65;
                    break;
                case 3:
                    fin=price*0.6;
                    break;
            }
        }
        return fin;
    }*/







    /*
    public static String ge(int len){
        String code = "";
        char[] chs = {'a','b','c','d','e','f','g','h','i','j','k',
                'l','m','n','o','p','q','r','s','t','u','v',
                'w','x','y','z','A','B','C','D','E','F','G',
                'H','I','J','K','L','M','N','O','P','Q','R',
                'S','T','U','V','W','X','Y','Z','0','1','2',
                '3','4','5','6','7','8','9'};
        Random rand = new Random();
        for (int i=1;i<len;i++){
            int index=rand.nextInt(chs.length);
            code+=chs[index];
        }
    }*/
}
